package com.jiangxiaofei.citycloud.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.baidu.mapapi.search.core.PoiInfo;
import com.jiangxiaofei.citycloud.R;

import java.util.List;

/**
 * Created by Administrator on 2017/9/19 0019.
 */

public class CarSearchResultAdapter extends RecyclerView.Adapter<CarSearchResultAdapter.SearchViewHolder> {
    Context mContext;
    List<PoiInfo> poiInfos;

    public CarSearchResultAdapter(Context mContext, List<PoiInfo> poiInfos) {
        this.mContext = mContext;
        this.poiInfos = poiInfos;
    }

    @Override
    public SearchViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_car_map_search_result_layout, parent);
        SearchViewHolder viewHolder = new SearchViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(SearchViewHolder holder, int position) {
        holder.tv_item.setText(poiInfos.get(position).name);
    }

    @Override
    public int getItemCount() {
        return poiInfos.size();
    }

    class SearchViewHolder extends RecyclerView.ViewHolder {
        TextView tv_item;

        public SearchViewHolder(View itemView) {
            super(itemView);
            tv_item = itemView.findViewById(R.id.tv_items_car_map_search_result);
        }
    }
}
